from lib.oauth.OAuthClient import OAuthClient
import oauth.oauth as oauth
def test_function(url):
    import webbrowser
    webbrowser.open_new_tab(url)       
    raw_input()        
def test():
    try:
        key = 'c0b2ed64d274f0e14218c82e775ed2a3'
        secret = '35572ad8be9f5407'
        
        client = OAuthClient('09322d44580f77ab1b9687cd082e6701', '6cb041061e2f37d6')
        client.login(key, secret, function=test_function) 
        print client.access_resource('GET', 'http://api.douban.com/access_token/').read()     
    except oauth.OAuthError as e:
        print e.message    
if __name__ == "__main__":
    test()  